<?php
namespace App\Services\WxCommon;

/**
 * 微信基类
 * @package App\Services\WxCommon
 */
class WxBase
{
    /**
     * 微信应用ID
     * @var
     */
    protected $appid;
    /**
     * 微信应用对象
     * @var
     */
    protected $app;

    /**
     * 构造函数
     * @param $appid
     */
    public function __construct($appid = '')
    {
        if (empty($appid)){
            $curWxMp = \Auth::user()->getWxMpCurrent();
            $this->appid = $curWxMp ? $curWxMp['appid'] : '';
        }else{
            $this->appid = $appid;
        }
        if (empty($this->appid)){
            throw new \Exception('当前无可用微信应用');
        }
    }
}